#ifndef __STATE_MACHINE_V1_H__
#define __STATE_MACHINE_V1_H__

#include <functional>
#include <iostream>
#include <vector>

enum class State
{
    AT_HOME,  // 在家状态
    OUTSIDE   // 外出状态
};

enum class Event
{
    RAINING,  // 下雨事件
    SUNNY     // 晴天事件
};

class StateMachine
{
  public:
    using StateAction = std::function<void()>;

    struct Transition
    {
        State current;
        Event event;
        State next;
        StateAction transition_action;  // 转移时执行的动作
        StateAction enter_action;       // 进入新状态的动作
    };

    StateMachine();
    void handleEvent(Event event);
    State getCurrentState() const;

  private:
    void setupTransitions();

    State current_state;
    std::vector<Transition> transitions;
};

void testStateMachine();

#endif  // __STATE_MACHINE_V1_H__